#include <cassert>
#include <iostream>
#include <vector>
using namespace std;
#include <chrono>
#include <cstdio>

void MyTimer(int type, const char *info = nullptr) {
  static std::chrono::steady_clock::time_point start;
  if (type == 0) {
    start = std::chrono::steady_clock::now();
    printf("Begin %s\n", info);
    return;
  } else {
    auto end = std::chrono::steady_clock::now();
    auto dt =
        std::chrono::duration_cast<std::chrono::duration<double>>(end - start);
    printf("End %s, time taken=%lf\n", info, dt.count());
  }
}

int main() {
  const int n = 100000000; // 一亿

  vector<bool> vec_bool(n);
  MyTimer(0, "bool");
  for (int i = 0; i < n; ++i) {
    vec_bool[i] = true;
  }
  int sum_bool{0};
  for (int i = 0; i < n; ++i) {
    sum_bool += vec_bool[i];
  }
  MyTimer(1, "bool");

  cout << sum_bool << endl;

  vector<int> vec_int(n);
  MyTimer(0, "int");
  for (int i = 0; i < n; ++i) {
    vec_int[i] = 1;
  }
  int sum_int{0};
  for (int i = 0; i < n; ++i) {
    sum_int += vec_int[i];
  }
  MyTimer(1, "int");
  cout << sum_int << endl;

  vector<short> vec_short(n);
  MyTimer(0, "short");
  for (int i = 0; i < n; ++i) {
    vec_short[i] = 1;
  }
  int sum_short{0};
  for (int i = 0; i < n; ++i) {
    sum_short += vec_short[i];
  }
  MyTimer(1, "short");

  cout << sum_short << endl;

  bool *arr_bool = new bool[n];
  MyTimer(0, "array_bool");
  for (int i = 0; i < n; ++i) {
    arr_bool[i] = true;
  }
  int sum_array_bool{0};
  for (int i = 0; i < n; ++i) {
    sum_array_bool += arr_bool[i];
  }
  MyTimer(1, "array_bool");
  cout << sum_array_bool << endl;
  delete[] arr_bool;

  int *arr_int = new int[n];
  // int arr_int[n];
  MyTimer(0, "array_int");
  for (int i = 0; i < n; ++i) {
    arr_int[i] = 1;
  }
  int sum_array_int{0};
  for (int i = 0; i < n; ++i) {
    sum_array_int += arr_int[i];
  }
  MyTimer(1, "array_int");
  cout << sum_array_int << endl;
  delete[] arr_int;

  return 0;
}